<?php

use app\assets\ApiAsset;
use app\assets\LayerAsset;
use app\assets\TableAsset;
use app\models\KeyMap;
use app\models\UserCardReservereserve;
use app\widgets\LinkPager;
use app\widgets\ManagerTableOp;
use yii\helpers\Html;
use yii\helpers\Url;
use dosamigos\datepicker\DatePicker;
/**
 * @var $this yii\web\View
 * @var $reserveList app\models\UserCardreserve[]
 * @var $pagination yii\data\Pagination
 */

ApiAsset::register($this);
LayerAsset::register($this);
TableAsset::register($this);

$this->title = '卡预充值列表';
$this->params['breadcrumbs'][] = '财务管理';
$this->params['breadcrumbs'][] = $this->title;
?>
<?php echo Html::beginForm('?', 'get', ['class'=>'form-inline']);?>
<div class="form-group">
    <label for="search_status" class="sr-only">执行状态</label>
    <?php echo Html::dropDownList('search_status',Yii::$app->request->get('search_status'),
        KeyMap::getValues('execute_status'),['id'=>'search_status','class' => 'form-control',
        'prompt' => '执行状态']);?>
</div>
<div class="form-group">
    <label for="search_iccid" class="sr-only">ICCID</label>
    <?php echo Html::textInput('search_iccid', Yii::$app->request->get('search_iccid'), ['id'=>'search_iccid', 'class'=>'form-control', 'placeholder'=>'ICCID', 'style' => 'min-width:180px;']);?>
</div>
<div class="form-group">
    <label for="time">时间</label>
    <?php echo DatePicker::widget([ 
        'name' => 'search_time', 
        'options' => ['placeholder' => '时间'], 
        'attribute' => 'time',
        'template' => '{addon}{input}',
        'value' => $current_time,
        'clientOptions' => [ 
            'autoclose' => true, 
            'format' => 'yyyy-mm-dd',
            'todayHighlight' => true, 
        ] 
    ]); ?>
</div>
<div class="form-group">
    <button class="btn btn-primary btn-sm">搜索</button>
</div>
<?php echo Html::endForm();?>
<table class="table table-striped table-bordered table-hover">
    <thead>
    <tr>
        <th class="center">
            <label class="pos-rel">
                <span class="lbl">编号</span>
            </label>
        </th>
        <th class="center">代理商</th>
        <th class="center">ICCID/MSISDN/IMSI</th>
        <th class="center">套餐</th>
        <th class="center">充值时长</th>
        <th class="center">金额</th>
        <th class="center">支付</th>
        <th class="center">订单号</th>
        <th class="center">是否执行充值</th>
        <th class="center">激活时间</th>
        <th class="center">来源</th>
        <th class="center">创建时间</th>
        
    </tr>
    </thead>

    <tbody>
    <?php foreach ($reserveList as $reserve) {?>
        <tr>
            <td class="center"><label class="pos-rel"><span class="lbl"><?php echo $reserve->id;?></span></label></td>
            <td class="center"><?php echo empty($reserve->agent_id) ? '----' : Html::a(Html::encode($reserve->agent->username), ['/admin/user/agent-view', 'id' => $reserve->agent_id]);?></td>
            <td class="center"><?php echo empty($reserve->card->iccid) ? '----' : Html::encode($reserve->card->iccid);
                echo '<br />';
                echo empty($reserve->card->msisdn) ? '----' : Html::encode($reserve->card->msisdn);
                echo '<br />';
                echo empty($reserve->card->imsi) ? '----' : Html::encode($reserve->card->imsi);?></td>
            <td class="center"><?php echo Html::encode($reserve->package->name);?></td>
            <td class="center"><?php echo $reserve->term_length, KeyMap::getValue('card_term_length_unit', $reserve->term_length_unit);?></td>
            <td class="center"><?php echo $reserve->money;?></td>
            <td class="center"><?php echo KeyMap::getValue('user_card_recharge_trade_type', $reserve->trade_type);?></td>
            <td class="center"><?php echo Html::encode($reserve->order_sn);?></td>
            <td class="center"><?php echo KeyMap::getValue('execute_status',$reserve->execute_status);?></td>
            <td class="center"><?php echo Yii::$app->formatter->asDate($reserve->active_time);?></td>
            <td class="center"><?php echo KeyMap::getValue('source',$reserve->source);?></td>
            <td class="center"><?php echo Yii::$app->formatter->asDatetime($reserve->create_time);?></td>
            
        </tr>
    <?php }?>
    </tbody>
</table>
<?php echo LinkPager::widget(['pagination' => $pagination]);?>

